import React, { Component } from "react";
import PropTypes from "prop-types";

export default class Parent extends Component {
  render() {
    return (
      <>
        <h2>Parent</h2>
        <A name="wukong" age="20" />
      </>
    );
  }
}

class A extends Component {
  static propTypes = {
    name: PropTypes.string.isRequired,
    age: PropTypes.number,
    sex: PropTypes.string,
  };

  static defaultProps = {
    sex: "female",
  };
  render() {
    const { name, age, sex } = this.props;
    return (
      <>
        <h3>A Child</h3>
        <div>{name}</div>
        <div>{age}</div>
        <div>{sex}</div>
      </>
    );
  }
}
